﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:w="http://schemas.jelle.druyts.net/2010/xaml/presentation"
             xmlns:sm="clr-namespace:Schedulr.Models;assembly=Schedulr.Common"
             x:Class="Schedulr.Views.ConfigurationEditor"
             mc:Ignorable="d"
             w:MergeCollections.InputBindings="{Binding InputBindings}"
             DataContext="{Binding Path=ConfigurationEditorViewModel, Source={StaticResource Locator}}">
    <UserControl.Resources>
        <DataTemplate DataType="{x:Type sm:Account}">
            <StackPanel Orientation="Horizontal">
                <Border x:Name="pictureBorder" Style="{DynamicResource BorderStyle}" Background="Transparent" Padding="5" Margin="5">
                    <w:BackgroundLoadingImage Source="/Resources/Anonymous.png" ActualSource="{Binding Path=UserInfo.BuddyIconUrl}" Width="48" Height="48" />
                </Border>
                <TextBlock x:Name="nameTextBlock" Text="{Binding Name}" VerticalAlignment="Center" FontWeight="Bold" Foreground="{DynamicResource UserMessageFontBrush}" />
            </StackPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
                    <Setter TargetName="pictureBorder" Property="BorderBrush" Value="{DynamicResource ImageBorderBorderBrush}" />
                    <Setter TargetName="pictureBorder" Property="Background" Value="{DynamicResource ImageBorderFillBrush}" />
                    <Setter TargetName="nameTextBlock" Property="Foreground" Value="{DynamicResource TextBrush}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding IsDefaultAccount}" Value="True">
                    <Setter TargetName="nameTextBlock" Property="TextDecorations" Value="Underline" />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </UserControl.Resources>
    <StackPanel>

        <Border Padding="5,0,5,0" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5,5,0,0" Height="35">
            <TextBlock Padding="4,0,0,0" Text="Manage your Flickr accounts" TextWrapping="Wrap" Foreground="{DynamicResource HeaderFontColor}" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" />
        </Border>

        <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Background="{DynamicResource BackgroundBrush}">
            <DockPanel LastChildFill="True">
                <Border DockPanel.Dock="Right" Style="{DynamicResource BorderStyle}" Background="{DynamicResource DiagramGradientBrush}" Margin="0,5,5,5">
                    <ItemsControl DockPanel.Dock="Right" ItemsSource="{Binding ActionsCommands}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button Content="{Binding Name}" ToolTip="{Binding Description}" Command="{Binding}" Margin="5" />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Border>
                <Border Style="{DynamicResource BorderStyle}" Background="{DynamicResource DiagramGradientBrush}" Margin="5" MinWidth="300">
                    <DockPanel LastChildFill="True">
                        <ItemsControl DockPanel.Dock="Bottom" ItemsSource="{Binding SelectedAccountCommands}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Button Content="{Binding Name}" ToolTip="{Binding Description}" Command="{Binding}" Margin="5" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                        <ListBox SelectedItem="{Binding Path=SelectedAccount, Mode=TwoWay}" ItemsSource="{Binding Accounts}" Background="Transparent" BorderThickness="0">
                            <ListBox.Resources>
                                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
                            </ListBox.Resources>
                        </ListBox>
                    </DockPanel>
                </Border>
            </DockPanel>
        </Border>

        <Border Background="{DynamicResource BackgroundBrush}" Height="35" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="0,0,5,5" Padding="5,0,5,0">
            <ItemsControl ItemsSource="{Binding DialogCommands}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button Content="{Binding Name}" ToolTip="{Binding Description}" Command="{Binding}" Margin="5,0,0,0" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Border>

    </StackPanel>
</UserControl>